package c.c.b.a.b;

import c.c.b.a.a.e;
import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import com.pgl.sys.ces.out.ISdkLite;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* compiled from: HttpUrl */
public final class w {
    public static final char[] j = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    public final String a;
    public final String b;
    public final String c;
    public final String d;
    public final int e;
    public final List<String> f;
    public final List<String> g;
    public final String h;
    public final String i;

    /* compiled from: HttpUrl */
    public static final class a {
        public String a;
        public String b;
        public String c;
        public String d;
        public int e = -1;
        public final List<String> f;
        public List<String> g;
        public String h;

        /* compiled from: HttpUrl */
        public enum a {
            SUCCESS,
            MISSING_SCHEME,
            UNSUPPORTED_SCHEME,
            INVALID_PORT,
            INVALID_HOST
        }

        public a() {
            String str = "";
            this.b = str;
            this.c = str;
            ArrayList arrayList = new ArrayList();
            this.f = arrayList;
            arrayList.add(str);
        }

        /* JADX WARNING: Removed duplicated region for block: B:128:0x0250  */
        /* JADX WARNING: Removed duplicated region for block: B:128:0x0250  */
        /* JADX WARNING: Removed duplicated region for block: B:37:0x0091  */
        /* JADX WARNING: Removed duplicated region for block: B:29:0x0064  */
        /* JADX WARNING: Removed duplicated region for block: B:187:0x00ac A:{SYNTHETIC, EDGE_INSN: B:187:0x00ac->B:46:0x00ac ?: BREAK  , EDGE_INSN: B:187:0x00ac->B:46:0x00ac ?: BREAK  } */
        /* JADX WARNING: Removed duplicated region for block: B:42:0x009f  */
        /* JADX WARNING: Removed duplicated region for block: B:60:0x0106  */
        /* JADX WARNING: Removed duplicated region for block: B:59:0x0101  */
        /* JADX WARNING: Removed duplicated region for block: B:83:0x019c  */
        /* JADX WARNING: Removed duplicated region for block: B:109:0x01ec  */
        /* JADX WARNING: Removed duplicated region for block: B:97:0x01bd  */
        /* JADX WARNING: Removed duplicated region for block: B:114:0x0206  */
        /* JADX WARNING: Removed duplicated region for block: B:112:0x0203  */
        /* JADX WARNING: Missing block: B:25:0x005b, code skipped:
            if (r7 == ':') goto L_0x0062;
     */
        /* JADX WARNING: Missing block: B:102:0x01e0, code skipped:
            if (r1 <= 65535) goto L_0x01e4;
     */
        public c.c.b.a.b.w.a.a a(c.c.b.a.b.w r22, java.lang.String r23) {
            /*
            r21 = this;
            r0 = r21;
            r1 = r22;
            r10 = r23;
            r2 = r23.length();
            r3 = 0;
            r8 = c.c.b.a.b.a.e.b(r10, r3, r2);
            r2 = r23.length();
            r11 = c.c.b.a.b.a.e.u(r10, r8, r2);
            r2 = r11 - r8;
            r9 = 2;
            r12 = 58;
            r13 = -1;
            if (r2 >= r9) goto L_0x0020;
        L_0x001f:
            goto L_0x0061;
        L_0x0020:
            r2 = r10.charAt(r8);
            r3 = 90;
            r4 = 122; // 0x7a float:1.71E-43 double:6.03E-322;
            r5 = 65;
            r6 = 97;
            if (r2 < r6) goto L_0x0030;
        L_0x002e:
            if (r2 <= r4) goto L_0x0035;
        L_0x0030:
            if (r2 < r5) goto L_0x0061;
        L_0x0032:
            if (r2 <= r3) goto L_0x0035;
        L_0x0034:
            goto L_0x0061;
        L_0x0035:
            r2 = r8;
        L_0x0036:
            r2 = r2 + 1;
            if (r2 >= r11) goto L_0x0061;
        L_0x003a:
            r7 = r10.charAt(r2);
            if (r7 < r6) goto L_0x0042;
        L_0x0040:
            if (r7 <= r4) goto L_0x005e;
        L_0x0042:
            if (r7 < r5) goto L_0x0046;
        L_0x0044:
            if (r7 <= r3) goto L_0x005e;
        L_0x0046:
            r3 = 48;
            if (r7 < r3) goto L_0x004e;
        L_0x004a:
            r3 = 57;
            if (r7 <= r3) goto L_0x005e;
        L_0x004e:
            r3 = 43;
            if (r7 == r3) goto L_0x005e;
        L_0x0052:
            r3 = 45;
            if (r7 == r3) goto L_0x005e;
        L_0x0056:
            r3 = 46;
            if (r7 != r3) goto L_0x005b;
        L_0x005a:
            goto L_0x005e;
        L_0x005b:
            if (r7 != r12) goto L_0x0061;
        L_0x005d:
            goto L_0x0062;
        L_0x005e:
            r3 = 90;
            goto L_0x0036;
        L_0x0061:
            r2 = -1;
        L_0x0062:
            if (r2 == r13) goto L_0x0091;
        L_0x0064:
            r3 = 1;
            r6 = 0;
            r7 = 6;
            r5 = "https:";
            r2 = r23;
            r4 = r8;
            r2 = r2.regionMatches(r3, r4, r5, r6, r7);
            if (r2 == 0) goto L_0x0079;
        L_0x0072:
            r2 = "https";
            r0.a = r2;
            r8 = r8 + 6;
            goto L_0x0097;
        L_0x0079:
            r3 = 1;
            r6 = 0;
            r7 = 5;
            r5 = "http:";
            r2 = r23;
            r4 = r8;
            r2 = r2.regionMatches(r3, r4, r5, r6, r7);
            if (r2 == 0) goto L_0x008e;
        L_0x0087:
            r2 = "http";
            r0.a = r2;
            r8 = r8 + 5;
            goto L_0x0097;
        L_0x008e:
            r1 = c.c.b.a.b.w.a.a.UNSUPPORTED_SCHEME;
            return r1;
        L_0x0091:
            if (r1 == 0) goto L_0x0353;
        L_0x0093:
            r2 = r1.a;
            r0.a = r2;
        L_0x0097:
            r2 = 0;
            r3 = r8;
        L_0x0099:
            r4 = 47;
            r5 = 92;
            if (r3 >= r11) goto L_0x00ac;
        L_0x009f:
            r6 = r10.charAt(r3);
            if (r6 == r5) goto L_0x00a7;
        L_0x00a5:
            if (r6 != r4) goto L_0x00ac;
        L_0x00a7:
            r2 = r2 + 1;
            r3 = r3 + 1;
            goto L_0x0099;
        L_0x00ac:
            r3 = 63;
            r6 = 35;
            if (r2 >= r9) goto L_0x00f2;
        L_0x00b2:
            if (r1 == 0) goto L_0x00f2;
        L_0x00b4:
            r7 = r1.a;
            r9 = r0.a;
            r7 = r7.equals(r9);
            if (r7 != 0) goto L_0x00bf;
        L_0x00be:
            goto L_0x00f2;
        L_0x00bf:
            r2 = r22.k();
            r0.b = r2;
            r2 = r22.l();
            r0.c = r2;
            r2 = r1.d;
            r0.d = r2;
            r2 = r1.e;
            r0.e = r2;
            r2 = r0.f;
            r2.clear();
            r2 = r0.f;
            r3 = r22.n();
            r2.addAll(r3);
            if (r8 == r11) goto L_0x00e9;
        L_0x00e3:
            r2 = r10.charAt(r8);
            if (r2 != r6) goto L_0x0207;
        L_0x00e9:
            r1 = r22.o();
            r0.c(r1);
            goto L_0x0207;
        L_0x00f2:
            r8 = r8 + r2;
            r1 = 0;
            r2 = 0;
            r2 = r8;
            r1 = -1;
            r13 = 0;
            r14 = 0;
        L_0x00f9:
            r7 = "@/\\?#";
            r15 = c.c.b.a.b.a.e.d(r10, r2, r11, r7);
            if (r15 == r11) goto L_0x0106;
        L_0x0101:
            r7 = r10.charAt(r15);
            goto L_0x0107;
        L_0x0106:
            r7 = -1;
        L_0x0107:
            if (r7 == r1) goto L_0x0199;
        L_0x0109:
            if (r7 == r6) goto L_0x0199;
        L_0x010b:
            if (r7 == r4) goto L_0x0199;
        L_0x010d:
            if (r7 == r5) goto L_0x0199;
        L_0x010f:
            if (r7 == r3) goto L_0x0199;
        L_0x0111:
            r1 = 64;
            if (r7 == r1) goto L_0x0117;
        L_0x0115:
            goto L_0x018c;
        L_0x0117:
            r9 = "%40";
            if (r13 != 0) goto L_0x0161;
        L_0x011b:
            r8 = c.c.b.a.b.a.e.c(r10, r2, r15, r12);
            r5 = 1;
            r6 = 0;
            r7 = 0;
            r16 = 1;
            r17 = 0;
            r4 = " \"':;<=>@[]^`{}|/\\?#";
            r1 = r23;
            r3 = r8;
            r12 = r8;
            r8 = r16;
            r22 = r13;
            r13 = r9;
            r9 = r17;
            r1 = c.c.b.a.b.w.b(r1, r2, r3, r4, r5, r6, r7, r8, r9);
            if (r14 == 0) goto L_0x0144;
        L_0x0139:
            r2 = new java.lang.StringBuilder;
            r2.<init>();
            r3 = r0.b;
            r1 = c.b.a.a.a.e(r2, r3, r13, r1);
        L_0x0144:
            r0.b = r1;
            if (r12 == r15) goto L_0x015d;
        L_0x0148:
            r2 = r12 + 1;
            r5 = 1;
            r6 = 0;
            r7 = 0;
            r8 = 1;
            r9 = 0;
            r4 = " \"':;<=>@[]^`{}|/\\?#";
            r1 = r23;
            r3 = r15;
            r1 = c.c.b.a.b.w.b(r1, r2, r3, r4, r5, r6, r7, r8, r9);
            r0.c = r1;
            r1 = 1;
            r13 = 1;
            goto L_0x015f;
        L_0x015d:
            r13 = r22;
        L_0x015f:
            r14 = 1;
            goto L_0x018a;
        L_0x0161:
            r22 = r13;
            r13 = r9;
            r12 = new java.lang.StringBuilder;
            r12.<init>();
            r1 = r0.c;
            r12.append(r1);
            r12.append(r13);
            r5 = 1;
            r6 = 0;
            r7 = 0;
            r8 = 1;
            r9 = 0;
            r4 = " \"':;<=>@[]^`{}|/\\?#";
            r1 = r23;
            r3 = r15;
            r1 = c.c.b.a.b.w.b(r1, r2, r3, r4, r5, r6, r7, r8, r9);
            r12.append(r1);
            r1 = r12.toString();
            r0.c = r1;
            r13 = r22;
        L_0x018a:
            r2 = r15 + 1;
        L_0x018c:
            r6 = 35;
            r3 = 63;
            r5 = 92;
            r4 = 47;
            r1 = -1;
            r12 = 58;
            goto L_0x00f9;
        L_0x0199:
            r1 = r2;
        L_0x019a:
            if (r1 >= r15) goto L_0x01b8;
        L_0x019c:
            r3 = r10.charAt(r1);
            r4 = 58;
            if (r3 == r4) goto L_0x01b9;
        L_0x01a4:
            r5 = 91;
            if (r3 == r5) goto L_0x01aa;
        L_0x01a8:
            r3 = 1;
            goto L_0x01b6;
        L_0x01aa:
            r3 = 1;
        L_0x01ab:
            r1 = r1 + r3;
            if (r1 >= r15) goto L_0x01b6;
        L_0x01ae:
            r5 = r10.charAt(r1);
            r6 = 93;
            if (r5 != r6) goto L_0x01ab;
        L_0x01b6:
            r1 = r1 + r3;
            goto L_0x019a;
        L_0x01b8:
            r1 = r15;
        L_0x01b9:
            r3 = r1 + 1;
            if (r3 >= r15) goto L_0x01ec;
        L_0x01bd:
            r4 = 0;
            r1 = c.c.b.a.b.w.c(r10, r2, r1, r4);
            r1 = c.c.b.a.b.a.e.h(r1);
            r0.d = r1;
            r4 = "";
            r5 = 0;
            r6 = 0;
            r7 = 0;
            r8 = 1;
            r9 = 0;
            r1 = r23;
            r2 = r3;
            r3 = r15;
            r1 = c.c.b.a.b.w.b(r1, r2, r3, r4, r5, r6, r7, r8, r9);	 Catch:{ NumberFormatException -> 0x01e3 }
            r1 = java.lang.Integer.parseInt(r1);	 Catch:{ NumberFormatException -> 0x01e3 }
            if (r1 <= 0) goto L_0x01e3;
        L_0x01dd:
            r2 = 65535; // 0xffff float:9.1834E-41 double:3.23786E-319;
            if (r1 > r2) goto L_0x01e3;
        L_0x01e2:
            goto L_0x01e4;
        L_0x01e3:
            r1 = -1;
        L_0x01e4:
            r0.e = r1;
            r2 = -1;
            if (r1 != r2) goto L_0x01ff;
        L_0x01e9:
            r1 = c.c.b.a.b.w.a.a.INVALID_PORT;
            return r1;
        L_0x01ec:
            r3 = 0;
            r1 = c.c.b.a.b.w.c(r10, r2, r1, r3);
            r1 = c.c.b.a.b.a.e.h(r1);
            r0.d = r1;
            r1 = r0.a;
            r1 = c.c.b.a.b.w.a(r1);
            r0.e = r1;
        L_0x01ff:
            r1 = r0.d;
            if (r1 != 0) goto L_0x0206;
        L_0x0203:
            r1 = c.c.b.a.b.w.a.a.INVALID_HOST;
            return r1;
        L_0x0206:
            r8 = r15;
        L_0x0207:
            r1 = "?#";
            r1 = c.c.b.a.b.a.e.d(r10, r8, r11, r1);
            if (r8 != r1) goto L_0x0216;
        L_0x020f:
            r13 = r0;
            r3 = r1;
            r1 = r10;
            r2 = r1;
        L_0x0213:
            r12 = r11;
            goto L_0x030e;
        L_0x0216:
            r2 = r10.charAt(r8);
            r3 = "";
            r4 = 47;
            if (r2 == r4) goto L_0x0239;
        L_0x0220:
            r4 = 92;
            if (r2 != r4) goto L_0x0225;
        L_0x0224:
            goto L_0x0239;
        L_0x0225:
            r2 = r0.f;
            r4 = r2.size();
            r4 = r4 + -1;
            r2.set(r4, r3);
            r7 = r0;
            r9 = r7;
            r4 = r1;
            r6 = r3;
            r13 = r8;
            r2 = r10;
            r3 = r4;
            r1 = r2;
            goto L_0x024e;
        L_0x0239:
            r2 = 1;
            r4 = r0.f;
            r4.clear();
            r4 = r0.f;
            r4.add(r3);
            r7 = r0;
            r9 = r7;
            r4 = r1;
            r6 = r3;
            r2 = r10;
            r5 = 1;
            r3 = r4;
            r1 = r2;
        L_0x024c:
            r8 = r8 + r5;
        L_0x024d:
            r13 = r8;
        L_0x024e:
            if (r13 >= r4) goto L_0x030a;
        L_0x0250:
            r5 = "/\\";
            r8 = c.c.b.a.b.a.e.d(r1, r13, r4, r5);
            if (r8 >= r4) goto L_0x025a;
        L_0x0258:
            r5 = 1;
            goto L_0x025b;
        L_0x025a:
            r5 = 0;
        L_0x025b:
            r16 = 1;
            r17 = 0;
            r18 = 0;
            r19 = 1;
            r20 = 0;
            r15 = " \"<>^`{}|/\\?#";
            r12 = r1;
            r14 = r8;
            r12 = c.c.b.a.b.w.b(r12, r13, r14, r15, r16, r17, r18, r19, r20);
            r13 = ".";
            r13 = r12.equals(r13);
            if (r13 != 0) goto L_0x0280;
        L_0x0275:
            r13 = "%2e";
            r13 = r12.equalsIgnoreCase(r13);
            if (r13 == 0) goto L_0x027e;
        L_0x027d:
            goto L_0x0280;
        L_0x027e:
            r13 = 0;
            goto L_0x0281;
        L_0x0280:
            r13 = 1;
        L_0x0281:
            if (r13 == 0) goto L_0x0285;
        L_0x0283:
            goto L_0x0305;
        L_0x0285:
            r13 = "..";
            r13 = r12.equals(r13);
            if (r13 != 0) goto L_0x02a8;
        L_0x028d:
            r13 = "%2e.";
            r13 = r12.equalsIgnoreCase(r13);
            if (r13 != 0) goto L_0x02a8;
        L_0x0295:
            r13 = ".%2e";
            r13 = r12.equalsIgnoreCase(r13);
            if (r13 != 0) goto L_0x02a8;
        L_0x029d:
            r13 = "%2e%2e";
            r13 = r12.equalsIgnoreCase(r13);
            if (r13 == 0) goto L_0x02a6;
        L_0x02a5:
            goto L_0x02a8;
        L_0x02a6:
            r13 = 0;
            goto L_0x02a9;
        L_0x02a8:
            r13 = 1;
        L_0x02a9:
            if (r13 == 0) goto L_0x02d9;
        L_0x02ab:
            r12 = r9.f;
            r13 = r12.size();
            r13 = r13 + -1;
            r12 = r12.remove(r13);
            r12 = (java.lang.String) r12;
            r12 = r12.isEmpty();
            if (r12 == 0) goto L_0x02d3;
        L_0x02bf:
            r12 = r9.f;
            r12 = r12.isEmpty();
            if (r12 != 0) goto L_0x02d3;
        L_0x02c7:
            r12 = r9.f;
            r13 = r12.size();
            r13 = r13 + -1;
            r12.set(r13, r6);
            goto L_0x0305;
        L_0x02d3:
            r12 = r9.f;
            r12.add(r6);
            goto L_0x0305;
        L_0x02d9:
            r13 = r9.f;
            r14 = r13.size();
            r14 = r14 + -1;
            r13 = r13.get(r14);
            r13 = (java.lang.String) r13;
            r13 = r13.isEmpty();
            if (r13 == 0) goto L_0x02f9;
        L_0x02ed:
            r13 = r9.f;
            r14 = r13.size();
            r14 = r14 + -1;
            r13.set(r14, r12);
            goto L_0x02fe;
        L_0x02f9:
            r13 = r9.f;
            r13.add(r12);
        L_0x02fe:
            if (r5 == 0) goto L_0x0305;
        L_0x0300:
            r12 = r9.f;
            r12.add(r6);
        L_0x0305:
            if (r5 == 0) goto L_0x024d;
        L_0x0307:
            r5 = 1;
            goto L_0x024c;
        L_0x030a:
            r13 = r7;
            r1 = r10;
            goto L_0x0213;
        L_0x030e:
            if (r3 >= r12) goto L_0x0335;
        L_0x0310:
            r4 = r2.charAt(r3);
            r5 = 63;
            if (r4 != r5) goto L_0x0335;
        L_0x0318:
            r14 = 35;
            r15 = c.c.b.a.b.a.e.c(r2, r3, r12, r14);
            r4 = r3 + 1;
            r7 = 1;
            r8 = 0;
            r9 = 1;
            r10 = 1;
            r11 = 0;
            r6 = " \"'<>#";
            r3 = r1;
            r5 = r15;
            r3 = c.c.b.a.b.w.b(r3, r4, r5, r6, r7, r8, r9, r10, r11);
            r3 = c.c.b.a.b.w.i(r3);
            r13.g = r3;
            r3 = r15;
            goto L_0x0337;
        L_0x0335:
            r14 = 35;
        L_0x0337:
            if (r3 >= r12) goto L_0x0350;
        L_0x0339:
            r2 = r2.charAt(r3);
            if (r2 != r14) goto L_0x0350;
        L_0x033f:
            r4 = r3 + 1;
            r7 = 1;
            r8 = 0;
            r9 = 0;
            r10 = 0;
            r11 = 0;
            r6 = "";
            r3 = r1;
            r5 = r12;
            r1 = c.c.b.a.b.w.b(r3, r4, r5, r6, r7, r8, r9, r10, r11);
            r13.h = r1;
        L_0x0350:
            r1 = c.c.b.a.b.w.a.a.SUCCESS;
            return r1;
        L_0x0353:
            r1 = c.c.b.a.b.w.a.a.MISSING_SCHEME;
            return r1;
            */
            throw new UnsupportedOperationException("Method not decompiled: c.c.b.a.b.w$a.a(c.c.b.a.b.w, java.lang.String):c.c.b.a.b.w$a$a");
        }

        public w b() {
            if (this.a == null) {
                throw new IllegalStateException("scheme == null");
            } else if (this.d != null) {
                return new w(this);
            } else {
                throw new IllegalStateException("host == null");
            }
        }

        public a c(String str) {
            List i;
            if (str != null) {
                i = w.i(w.d(str, " \"'<>#", true, false, true, true));
            } else {
                i = null;
            }
            this.g = i;
            return this;
        }

        public String toString() {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(this.a);
            stringBuilder.append("://");
            if (!(this.b.isEmpty() && this.c.isEmpty())) {
                stringBuilder.append(this.b);
                if (!this.c.isEmpty()) {
                    stringBuilder.append(':');
                    stringBuilder.append(this.c);
                }
                stringBuilder.append('@');
            }
            if (this.d.indexOf(58) != -1) {
                stringBuilder.append('[');
                stringBuilder.append(this.d);
                stringBuilder.append(']');
            } else {
                stringBuilder.append(this.d);
            }
            int i = this.e;
            if (i == -1) {
                i = w.a(this.a);
            }
            if (i != w.a(this.a)) {
                stringBuilder.append(':');
                stringBuilder.append(i);
            }
            List list = this.f;
            int size = list.size();
            for (int i2 = 0; i2 < size; i2++) {
                stringBuilder.append('/');
                stringBuilder.append((String) list.get(i2));
            }
            if (this.g != null) {
                stringBuilder.append('?');
                w.j(stringBuilder, this.g);
            }
            if (this.h != null) {
                stringBuilder.append('#');
                stringBuilder.append(this.h);
            }
            return stringBuilder.toString();
        }
    }

    public w(a aVar) {
        this.a = aVar.a;
        this.b = e(aVar.b, false);
        this.c = e(aVar.c, false);
        this.d = aVar.d;
        int i = aVar.e;
        if (i == -1) {
            i = a(aVar.a);
        }
        this.e = i;
        this.f = g(aVar.f, false);
        List list = aVar.g;
        String str = null;
        this.g = list != null ? g(list, true) : null;
        String str2 = aVar.h;
        if (str2 != null) {
            str = c(str2, 0, str2.length(), false);
        }
        this.h = str;
        this.i = aVar.toString();
    }

    public static int a(String str) {
        if (str.equals("http")) {
            return 80;
        }
        return str.equals("https") ? 443 : -1;
    }

    public static String b(String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset) {
        String str3 = str;
        int i3 = i2;
        String str4 = str2;
        int i4 = i;
        while (i4 < i3) {
            int codePointAt = str3.codePointAt(i4);
            if (codePointAt < 32 || codePointAt == 127 || ((codePointAt >= AesLen.ROOTKEY_COMPONET_LEN && z4) || str4.indexOf(codePointAt) != -1 || ((codePointAt == 37 && (!z || (z2 && !h(str3, i4, i3)))) || (codePointAt == 43 && z3)))) {
                e eVar = new e();
                eVar.t(str3, i, i4);
                e eVar2 = null;
                while (i4 < i3) {
                    int codePointAt2 = str3.codePointAt(i4);
                    if (!(z && (codePointAt2 == 9 || codePointAt2 == 10 || codePointAt2 == 12 || codePointAt2 == 13))) {
                        if (codePointAt2 == 43 && z3) {
                            eVar.s(z ? "+" : "%2B");
                        } else if (codePointAt2 < 32 || codePointAt2 == 127 || ((codePointAt2 >= AesLen.ROOTKEY_COMPONET_LEN && z4) || str4.indexOf(codePointAt2) != -1 || (codePointAt2 == 37 && (!z || (z2 && !h(str3, i4, i3)))))) {
                            if (eVar2 == null) {
                                eVar2 = new e();
                            }
                            eVar2.o(codePointAt2);
                            while (!eVar2.e()) {
                                int h = eVar2.h() & ISdkLite.REGION_UNSET;
                                eVar.h0(37);
                                char[] cArr = j;
                                eVar.h0(cArr[(h >> 4) & 15]);
                                eVar.h0(cArr[h & 15]);
                            }
                        } else {
                            eVar.o(codePointAt2);
                        }
                    }
                    i4 += Character.charCount(codePointAt2);
                }
                return eVar.A0();
            }
            i4 += Character.charCount(codePointAt);
        }
        int i5 = i;
        return str.substring(i, i2);
    }

    public static String c(String str, int i, int i2, boolean z) {
        int i3 = i;
        while (i3 < i2) {
            char charAt = str.charAt(i3);
            if (charAt == '%' || (charAt == '+' && z)) {
                e eVar = new e();
                eVar.t(str, i, i3);
                while (i3 < i2) {
                    i = str.codePointAt(i3);
                    if (i == 37) {
                        int i4 = i3 + 2;
                        if (i4 < i2) {
                            int a = c.c.b.a.b.a.e.a(str.charAt(i3 + 1));
                            int a2 = c.c.b.a.b.a.e.a(str.charAt(i4));
                            if (!(a == -1 || a2 == -1)) {
                                eVar.h0((a << 4) + a2);
                                i3 = i4;
                                i3 += Character.charCount(i);
                            }
                            eVar.o(i);
                            i3 += Character.charCount(i);
                        }
                    }
                    if (i == 43 && z) {
                        eVar.h0(32);
                        i3 += Character.charCount(i);
                    }
                    eVar.o(i);
                    i3 += Character.charCount(i);
                }
                return eVar.A0();
            }
            i3++;
        }
        return str.substring(i, i2);
    }

    public static String d(String str, String str2, boolean z, boolean z2, boolean z3, boolean z4) {
        return b(str, 0, str.length(), str2, z, z2, z3, z4, null);
    }

    public static String e(String str, boolean z) {
        return c(str, 0, str.length(), z);
    }

    public static boolean h(String str, int i, int i2) {
        int i3 = i + 2;
        if (i3 >= i2 || str.charAt(i) != '%' || c.c.b.a.b.a.e.a(str.charAt(i + 1)) == -1 || c.c.b.a.b.a.e.a(str.charAt(i3)) == -1) {
            return false;
        }
        return true;
    }

    public static List<String> i(String str) {
        ArrayList arrayList = new ArrayList();
        int i = 0;
        while (i <= str.length()) {
            int indexOf = str.indexOf(38, i);
            if (indexOf == -1) {
                indexOf = str.length();
            }
            int indexOf2 = str.indexOf(61, i);
            if (indexOf2 == -1 || indexOf2 > indexOf) {
                arrayList.add(str.substring(i, indexOf));
                arrayList.add(null);
            } else {
                arrayList.add(str.substring(i, indexOf2));
                arrayList.add(str.substring(indexOf2 + 1, indexOf));
            }
            i = indexOf + 1;
        }
        return arrayList;
    }

    public static void j(StringBuilder stringBuilder, List<String> list) {
        int size = list.size();
        for (int i = 0; i < size; i += 2) {
            String str = (String) list.get(i);
            String str2 = (String) list.get(i + 1);
            if (i > 0) {
                stringBuilder.append('&');
            }
            stringBuilder.append(str);
            if (str2 != null) {
                stringBuilder.append('=');
                stringBuilder.append(str2);
            }
        }
    }

    public boolean equals(Object obj) {
        return (obj instanceof w) && ((w) obj).i.equals(this.i);
    }

    public URI f() {
        String str;
        a aVar = new a();
        aVar.a = this.a;
        aVar.b = k();
        aVar.c = l();
        aVar.d = this.d;
        aVar.e = this.e != a(this.a) ? this.e : -1;
        aVar.f.clear();
        aVar.f.addAll(n());
        aVar.c(o());
        if (this.h == null) {
            str = null;
        } else {
            str = this.i.substring(this.i.indexOf(35) + 1);
        }
        aVar.h = str;
        int size = aVar.f.size();
        for (int i = 0; i < size; i++) {
            aVar.f.set(i, d((String) aVar.f.get(i), "[]", true, true, false, true));
        }
        List list = aVar.g;
        if (list != null) {
            size = list.size();
            for (int i2 = 0; i2 < size; i2++) {
                String str2 = (String) aVar.g.get(i2);
                if (str2 != null) {
                    aVar.g.set(i2, d(str2, "\\^`{|}", true, true, true, true));
                }
            }
        }
        String str3 = aVar.h;
        if (str3 != null) {
            aVar.h = d(str3, " \"#<>\\^`{|}", true, true, false, false);
        }
        String aVar2 = aVar.toString();
        try {
            return new URI(aVar2);
        } catch (URISyntaxException e) {
            try {
                return URI.create(aVar2.replaceAll("[\\u0000-\\u001F\\u007F-\\u009F\\p{javaWhitespace}]", ""));
            } catch (Exception unused) {
                throw new RuntimeException(e);
            }
        }
    }

    public final List<String> g(List<String> list, boolean z) {
        int size = list.size();
        ArrayList arrayList = new ArrayList(size);
        for (int i = 0; i < size; i++) {
            String str = (String) list.get(i);
            arrayList.add(str != null ? c(str, 0, str.length(), z) : null);
        }
        return Collections.unmodifiableList(arrayList);
    }

    public int hashCode() {
        return this.i.hashCode();
    }

    public String k() {
        if (this.b.isEmpty()) {
            return "";
        }
        int length = this.a.length() + 3;
        String str = this.i;
        return this.i.substring(length, c.c.b.a.b.a.e.d(str, length, str.length(), ":@"));
    }

    public String l() {
        if (this.c.isEmpty()) {
            return "";
        }
        return this.i.substring(this.i.indexOf(58, this.a.length() + 3) + 1, this.i.indexOf(64));
    }

    public String m() {
        int indexOf = this.i.indexOf(47, this.a.length() + 3);
        String str = this.i;
        return this.i.substring(indexOf, c.c.b.a.b.a.e.d(str, indexOf, str.length(), "?#"));
    }

    public List<String> n() {
        int indexOf = this.i.indexOf(47, this.a.length() + 3);
        String str = this.i;
        int d = c.c.b.a.b.a.e.d(str, indexOf, str.length(), "?#");
        ArrayList arrayList = new ArrayList();
        while (indexOf < d) {
            indexOf++;
            int c = c.c.b.a.b.a.e.c(this.i, indexOf, d, '/');
            arrayList.add(this.i.substring(indexOf, c));
            indexOf = c;
        }
        return arrayList;
    }

    public String o() {
        if (this.g == null) {
            return null;
        }
        int indexOf = this.i.indexOf(63) + 1;
        String str = this.i;
        return this.i.substring(indexOf, c.c.b.a.b.a.e.c(str, indexOf, str.length(), '#'));
    }

    public String toString() {
        return this.i;
    }
}
